package com.asp.alumnisystem.presenter;

import com.asp.alumnisystem.R;
import com.asp.alumnisystem.app.App;
import com.asp.alumnisystem.base.BaseBean;
import com.asp.alumnisystem.base.BasePresenter;
import com.asp.alumnisystem.base.IView;
import com.asp.alumnisystem.model.DetailsModel;
import com.asp.alumnisystem.net.RetrofitManager;
import com.asp.alumnisystem.utils.StringUtils;

import io.reactivex.Observable;

/**
 * 发布帖子回复信息的Presenter
 */
public class ReplyPresenter extends BasePresenter<String, DetailsModel> {

    private Long forumId;

    public ReplyPresenter(IView view, Long forumId) {
        super(view);
        this.forumId = forumId;
    }

    @Override
    protected boolean filter(String s) {
        if(StringUtils.isNull(s)){
            throw new RuntimeException("内容不能为空！");
        }
        return super.filter(s);
    }

    @Override
    protected Observable<BaseBean<DetailsModel>> requestNet(String s) {
        return RetrofitManager.getApi().reply(App.getApp().getUserId(), forumId, s);
    }

}
